package cn.wubo.message;

import cn.wubo.message.core.MessageService;
import cn.wubo.message.core.MessageType;
import cn.wubo.message.message.RequestContent;
import cn.wubo.message.message.SubLine;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class DemoController {

    @Resource
    MessageService messageService;

    @GetMapping(value = "/message/send")
    public String send() {
        return messageService.send(
                RequestContent.buildMarkdown()
                        .addAlias("dd-1", "dd-2", "dd-3")  //通过配置的别名指定消息通道
                        .addMessageType(MessageType.DingtalkCustomRobot) //通过消息通道类型指定消息通道
                        .addFeishuCustomRobot("", "")
                        .addDingtalkCustomRobot("isAtAll", Boolean.TRUE) //根据消息通道类型添加参数
                        .addDingtalkCustomRobot("dd-1", "isAtAll", Boolean.FALSE) //根据消息通道别名添加参数，优先级更大
                        .title("测试群发")
                        .addLine(SubLine.title("这是一行标题1", 1))
                        .addLine(SubLine.title("这是一行标题2", 2))
                        .addLine(SubLine.text("这是一行文本"))
                        .addLine(SubLine.link("这是一行链接", "https://gitee.com/wb04307201/message-spring-boot-starter"))
                        .addLine(SubLine.quote("这是一行引用"))
                        .addLine(SubLine.bold("这是一行加粗"))
        ).toString();
    }
}
